#!/usr/bin/env python
# Script for updating umitng database for new event storing schema.
# Author: Guilherme Polo <ggpolo@gmail.com>

import sys
from umitDB.InventoryChanges import UpdateChanges

def perform_update(database):
    """
    Executes update.
    """
    uc_instance = UpdateChanges(database)
    inv_ids = uc_instance.get_inventories_ids()
    inv_ids = [id[0] for id in inv_ids]
    
    for id in inv_ids:
        uc_instance.do_update(id)


if __name__ == "__main__":
    if len(sys.argv) < 2:
        print "You need to especify a database"
        raise SystemExit

    db = sys.argv[1]
    perform_update(db)
